# CMakeList.txt: MyCommon 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.8)
project(Demo01)

file(GLOB_RECURSE DEMO_INCLUDE ${PROJECT_SOURCE_DIR}/include/*.h ${PROJECT_SOURCE_DIR}/include/*.hpp)
file(GLOB_RECURSE DEMO_SRC ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.c)

#message(FATAL_ERROR ${DEMO_INCLUDE})
#message(FATAL_ERROR ${DEMO_SRC})
#message(FATAL_ERROR "CMAKE MODULE PATH IS ${CMAKE_MODULE_PATH}")

# 添加三方库依赖


message(WARNING ${PROJECT_SOURCE_DIR}/include)
include_directories(
	${PROJECT_SOURCE_DIR}/include/

	${SPDLOG_ROOT}/include
	#${BOOST_INCLUDE_DIRS}
	${PCL_INCLUDE_DIRS}
	${FLANN_INCLUDE_DIRS}
	${VTK_INCLUDE_DIRS}

	${OpenCV_INCLUDE_DIRS}

	${BOOST_INCLUDE_DIRS}

	${MYSDK_INCLUDE_DIRS}
)


add_library(${PROJECT_NAME} SHARED)

target_link_directories(${PROJECT_NAME}
	PUBLIC
	${PROJECT_SOURCE_DIR}/include
	
)

target_sources(${PROJECT_NAME}
	PRIVATE
	${DEMO_INCLUDE}
	${DEMO_SRC}
	
)

message(WARNING ${PCL_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME}
	PUBLIC
	#${BOOST_LIBRARIES}
	${PCL_LIBRARY_DIRS}
	${FLANN_LIBRARIES}
	${VTK_LIBRARIES}
	
	${OpenCV_LIBRARY_DIRS}

	${BOOST_LIBRARIES}

	${MYSDK_LIBRARIES}
)

#set(CMAKE_INSTALL_PREFIX ${WORKSPACE_PATH})
#message(FATAL_ERROR ${CMAKE_INSTALL_PREFIX})


# Windows下用Visual Studio得这么安装复制文件
if (IS_WINDOWS)
	add_definitions(-D_USRDLL -DDEMO_EXPORTS)

	# add_custom_command(
	# 	TARGET
	# 		${PROJECT_NAME}
	# 	POST_BUILD
	# 		COMMAND
	# 			${CMAKE_COMMAND} -E copy ${DEMO_INCLUDE} ${WORKSPACE_PATH}/include
	# 		COMMAND
	# 			${CMAKE_COMMAND} -E copy ${PROJECT_NAME}.dll ${WORKSPACE_PATH}/lib
	# 		COMMAND
	# 			${CMAKE_COMMAND} -E copy ${PROJECT_NAME}.lib ${WORKSPACE_PATH}/lib
	# 	VERBATIM
	# )

	if (DEFINED ENV{MYSDK_ROOT})
		# add_custom_command(
		# 	TARGET
		# 	${PROJECT_NAME}
		# POST_BUILD
		# 	COMMAND
		# 		${CMAKE_COMMAND} -E copy ${DEMO_INCLUDE} $ENV{MYSDK_ROOT}/include/Process
		# 	COMMAND
		# 		${CMAKE_COMMAND} -E copy ${PROJECT_NAME}.dll $ENV{MYSDK_ROOT}/bin
		# 	COMMAND
		# 		${CMAKE_COMMAND} -E copy ${PROJECT_NAME}.lib $ENV{MYSDK_ROOT}/lib
		# VERBATIM
		# )
	else()
		message(WARNING "ENV MYSDK_ROOT has not been defined!")
	endif()
endif()

# 在Linux上就可以这么安装
# if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# 	file(COPY ${DEMO_INCLUDE}
# 		DESTINATION
# 		${WORKSPACE_PATH}/include 
# 	)
# 	file(COPY ${DEMO_INCLUDE}
# 		DESTINATION
# 		$ENV{MYSDK_ROOT}/include/Process
# 	)

# 	install(TARGETS ${PROJECT_NAME}
# 		LIBRARY DESTINATION
# 		${WORKSPACE_PATH}/lib
# 		)

# 		install(TARGETS ${PROJECT_NAME}
# 		LIBRARY DESTINATION
# 		$ENV{MYSDK_ROOT}/lib
# 	)
# endif()
